<?php

namespace app\adminapi\controller\v1\notice;

use app\adminapi\controller\AuthController;
use app\services\notice\NoticeOtherService;
use think\facade\App;

class NoticeOther extends AuthController
{

    public function __construct(App $app,NoticeOtherService  $service)
    {
        parent::__construct($app);
        $this -> services = $service;
    }

    public function index(){
        $where = $this->request->getMore([
            ['website_id',$this  -> website],
            ['page',1],
            ['pageSize',20]
        ]);
        return app() -> make('json') -> successful($this -> services -> index($where));
    }

    public function create(){
        $where = $this->request->getMore([
            ['website_id',$this  -> website],
            ['user_ids',''],
            ['title',''],
            ['status',''],
            ['type',''],
            ['content',''],
        ]);
        return app() -> make('json') -> successful($this -> services -> create($where));
    }

    public function update(){
        $where = $this->request->getMore([
            ['id',''],
            ['title',''],
            ['status',''],
            ['type',''],
            ['content',''],
        ]);
        return app() -> make('json') -> successful($this -> services -> update($where));
    }

    public function delete(){
        $where = $this->request->getMore([
            ['website_id',$this  -> website],
            ['id','']
        ]);
        return app() -> make('json') -> successful($this -> services -> delete($where));
    }

    public function search(){
        $where = $this->request->getMore([
            ['website_id',$this  -> website],
            ['title',''],
            ['type',''],
            ['page',1],
            ['pageSize',20]
        ]);
        return app() -> make('json') -> successful($this -> services -> search($where));
    }


}